/*
Date:20210510 14:43PM
key:两个vector装着然后拿出来比较即可
 */
class Solution {
public:
    void F(TreeNode* root1,vector<int>&v1)
    {
        if(root1==nullptr){return;}
        if(root1->left==nullptr&&root1->right==nullptr)
        {
            v1.push_back(root1->val);
            return;
        }
        else
        {
            F(root1->left,v1);
            F(root1->right,v1);
        }
    }
    bool leafSimilar(TreeNode* root1, TreeNode* root2) 
    {
        vector<int>v1;
        vector<int>v2;
        F(root1,v1);
        F(root2,v2);
        if(v1.size()!=v2.size()){return 0;}
        for(int i=0;i<v1.size();i++)
        {
            if(v1[i]!=v2[i])
            {
                return 0;
            }
        }
        return 1;
    }
};